//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package org.springframework.security.oauth2.provider;

import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

abstract class BaseRequest implements Serializable {
    private String clientId;
    private Set<String> scope = new HashSet();
    private Map<String, String> requestParameters = Collections.unmodifiableMap(new HashMap());

    BaseRequest() {
    }

    public String getClientId() {
        return this.clientId;
    }

    public Set<String> getScope() {
        return this.scope;
    }

    public Map<String, String> getRequestParameters() {
        return this.requestParameters;
    }

    public int hashCode() {
        int result1 = 1;
        int result = 31 * result1 + (this.clientId == null ? 0 : this.clientId.hashCode());
        result = 31 * result + (this.requestParameters == null ? 0 : this.requestParameters.hashCode());
        result = 31 * result + (this.scope == null ? 0 : this.scope.hashCode());
        return result;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        } else if (obj == null) {
            return false;
        } else if (this.getClass() != obj.getClass()) {
            return false;
        } else {
            BaseRequest other = (BaseRequest)obj;
            if (this.clientId == null) {
                if (other.clientId != null) {
                    return false;
                }
            } else if (!this.clientId.equals(other.clientId)) {
                return false;
            }

            if (this.requestParameters == null) {
                if (other.requestParameters != null) {
                    return false;
                }
            } else if (!this.requestParameters.equals(other.requestParameters)) {
                return false;
            }

            if (this.scope == null) {
                if (other.scope != null) {
                    return false;
                }
            } else if (!this.scope.equals(other.scope)) {
                return false;
            }

            return true;
        }
    }

    protected void setScope(Collection<String> scope) {
        if (scope != null && ((Collection)scope).size() == 1) {
            String value = (String)((Collection)scope).iterator().next();
            if (value.contains(" ") || value.contains(",")) {
                scope = OAuth2Utils.parseParameterList(value);
            }
        }

        this.scope = Collections.unmodifiableSet(scope == null ? new LinkedHashSet() : new LinkedHashSet((Collection)scope));
    }

    protected void setRequestParameters(Map<String, String> requestParameters) {
        if (requestParameters != null) {
            this.requestParameters = Collections.unmodifiableMap(new HashMap(requestParameters));
        }

    }

    protected void setClientId(String clientId) {
        this.clientId = clientId;
    }
}
